<?php
$authedUser = $session->read('Auth.User');
echo $form->create('Review',array('url'=>'/'.$this->params['url']['url'],'id'=>'review_form','type'=>"file"));
?>
	<?php 
	if($reviewConfig['guest_write_review'] == 1 && empty($authedUser) && !isset($this->params['admin']))
	{
		$guestFields = cri('Users.Guest')->getFields('group', 'add');
		foreach($guestFields as $field)
		{
			echo $form->input('Guest.'.$field);
		}
	}?>
<?php
//this will set empty options for all fields.
$form->defaultEmpty = __("-Select-");
echo $form->input('Review.fake',array('type'=>'hidden'));
echo $form->inputs(array('fieldset'=>false),null,'add');
if(cr('ReviewConfig.upload_assets') && $session->read("Auth.User") && !@$this->params['admin'])
{
	if(isset($listingAssets))
	{
		echo "<div style=\"padding-top:10px;\">".$this->element('assets_on_edit_page',array("allowDefaultSelect"=>false)).'</div>';
	}
	echo "<div>";
		echo $form->input("assets");
	echo "</div>";
}
if($this->params['action'] == 'admin_edit')
{
	echo $form->input('id',array('type'=>'hidden'));
}
echo "<br />";
if(empty($authedUser) && $reviewConfig['captha_on_guest_review'] && !isset($this->params['admin']))
{
	echo $form->input('captcha', array('type'=>'captcha','class'=>'required'));
}
echo $form->end(__('Save'));
?>
<script type="text/javascript" src="/cms/js/jquery.validate.min.js"></script>
<script type='text/javascript'>
$(document).ready(function()
{
	$('#GuestName').parent('div').addClass('required');
	$('#GuestEmail').parent('div').addClass('required');
	
	$('.submit').live('click',function(e)
	{		
		if($("#review_form").valid()==false)
		{
			return;
		}
	});
});
</script>